package com.atguigu.proxy.dynamic;

/**
 * @program: design-patterns
 * @author: yangshen
 * @description:
 * @create: 2022-02-25 10:13
 **/
public class Client {
    public static void main(String[] args) {

        //创建一个目标对象
        TeacherDao target = new TeacherDao();

        //给目标对象创建代理对象,转化成 ITeacherDao(被代理对象的泛化)
        ITeacherDao proxyInstance =(ITeacherDao) new ProxyFactory(target).getProxyInstance();

        //proxyInstance = (有$符号，则为代理对象) class com.sun.proxy.$Proxy0, 内存中动态生成了代理对象
        System.out.println("proxyInstance = (有$符号，则为代理对象) ： " + proxyInstance.getClass());

        //通过代理对象，获取目标对象的方法
        proxyInstance.teach();
        proxyInstance.sayHello("tom");
    }
}
